home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sprite 1984 - 1993
/
Sprite 1984 - 1993.iso
/
src
/
lib
/
c
/
crt
/
symm.md
/
RCS
/
modf.c,v
< prev
Wrap
Text File
|
1990-09-26
|
2KB
|
83 lines
head 1.2;
branch ;
access ;
symbols ;
locks ; strict;
comment @ * @;
1.2
date 90.09.26.12.54.46; author kupfer; state Exp;
branches ;
next 1.1;
1.1
date 90.09.07.14.29.53; author kupfer; state Exp;
branches ;
next ;
desc
@modf() math routine.
@
1.2
log
@Include <math.h> to verify that we are declaring things correctly.
@
text
@/* $Copyright: $
* Copyright (c) 1984, 1985 Sequent Computer Systems, Inc.
* All rights reserved
*
* This software is furnished under a license and may be used
* only in accordance with the terms of that license and with the
* inclusion of the above copyright notice. This software may not
* be provided or otherwise made available to, or used by, any
* other person. No title to or ownership of the software is
* hereby transferred.
*/
/* $Header: /sprite/src/lib/c/crt/symm.md/RCS/modf.c,v 1.1 90/09/07 14:29:53 kupfer Exp Locker: kupfer $
*
* modf(value, iptr) returns the signed fractional part of value
* and stores the integer part indirectly through iptr.
*/
#include <values.h>
#include <math.h>
double
modf(value, iptr)
register double value;
register double *iptr;
{
register double absvalue;
if ((absvalue = (value >= 0.0) ? value : -value) >= MAXPOWTWO)
*iptr = value; /* it must be an integer */
else {
*iptr = absvalue + MAXPOWTWO; /* shift fraction off right */
*iptr -= MAXPOWTWO; /* shift back without fraction */
while (*iptr > absvalue) /* above arithmetic might round */
*iptr -= 1.0; /* test again just to be sure */
if (value < 0.0)
*iptr = -*iptr;
}
return (value - *iptr); /* signed fractional part */
}
@
1.1
log
@Initial revision
@
text
@d13 1
a13 1
/* $Header: modf.c 1.1 86/02/24 $
d20 1
@